<!--院外协同 销售管理 手术跟台详情（1.5.0版） -->
<template>
  <div class="purchasing-purchase-wholesale-detail">
    <el-container class="registercard-box">
      <!-- 驳回的备注，状态为驳回的时候显示 -->
      <h3
        v-if="topInfo.orderStatus === '已驳回'"
        style="color:red; margin:10px 0 10px 10px;">
        备注：
        <span style="color:#000;">{{ topInfo.remark }}</span>
      </h3>
      <!-- 待确认,已取消,待确认,已拒绝 -->
      <tabs
        :tabs-arr="tabSliceList"
        class="tab-info"
        @returnIndex="handleReturnIndex" />
      <div v-if="activeIndex === 0">
        <h3 class="title">病人信息</h3>
        <RecordInfo
          :record-form="patientInfoColumns"
          :record-data="topInfo"/>
        <file-list
          :file-list-arr="topInfo.fileUrl"
        />
        <h3 class="title">订单信息</h3>
        <RecordInfo
          :record-form="headerFrom"
          :record-data="topInfo">
          <template v-slot:recordInfoslot="slotProp">
            <div
              class="solt-info"
              v-if="activeIndex === 0||2||3">
              <span class="left-span">
                销售产品总数
                <span class="right-span">{{ topInfo.prodCount }}</span>
              </span>
              <span>
                品种数
                <span>{{ topInfo.prodTypeCount }}</span>
              </span>
              <span>
                金额合计（元）:
                <span class="price">{{ topInfo.orderTotalAmount | getFormatterPrice }}</span>
              </span>
            </div>
          </template>
        </RecordInfo>
        <el-editable
          class="purchase-wholesale-detail-table"
          height="600"
          :data="ordertableData"
          :columns="listColumns"
        >
          <template
            slot="default-registrationNumber"
            slot-scope="scope">
            <div>
              <cell-registration
                :key="scope.row.registrationNumber"
                :regis-no="scope.row.registrationNumber"
                :content="'注册证已过期，点击查看详细信息'"
                :status="scope.row.isNoExpire"
                :regis-data="scope.row.registrationInfo"
              />
            </div>
            <!-- <el-button
              :disabled="!scope.row.registrationNumber||!scope.row.registrationId"
              v-html="regisNoButton(scope.row)"
              type="text"
              @click="showPdfRegistion(scope.row.registrationId)"
            /> -->
          </template>
        </el-editable>
        <!-- 分页模块 -->
        <el-pagination
          align="right"
          style="margin-top:20px;"
          @size-change="sizeChange"
          @current-change="pageChange"
          :page-sizes="page.PAGE_NUMBER"
          :page-size="page.size"
          :current-page="page.page"
          :layout="page.PAGINATION_LAYOUT"
          :total="page.total"
        />
      </div>

      <!-- 收货信息 -->
      <div v-if="activeIndex === 1">
        <h3 class="title">订单信息</h3>
        <RecordInfo
          :record-form="headerFrom"
          :record-data="reciveTopInfo">
          <template v-slot:recordInfoslot="slotProp">
            <div
              class="solt-info"
              v-if="activeIndex === 1">
              <div>
                <span class="left-span">
                  发货单号
                  <span class="right-span">{{ reciveTopInfo.deliveryCode }}</span>
                </span>
                <span>
                  发货时间
                  <span>{{ reciveTopInfo.deliveryCreatedAt }}</span>
                </span>
                <span>
                  发货人:
                  <span>
                    <span>{{ reciveTopInfo.deliverer }}</span>
                  </span>
                </span>
              </div>
              <div>
                <span class="left-span">
                  发货产品总数
                  <span class="right-span">{{ reciveTopInfo.prodTotalCount }}</span>
                </span>
                <span>
                  品种数
                  <span>{{ reciveTopInfo.prodTypeCount }}</span>
                </span>
                <span>
                  金额合计:
                  <span>
                    <span class="price">{{ reciveTopInfo.orderAmount | getFormatterPrice }}</span>
                  </span>
                </span>
              </div>
            </div>
          </template>
        </RecordInfo>
        <el-editable
          class="purchase-wholesale-detail-table"
          height="400"
          :data="ordertableData"
          :columns="RecivePartialCollectionColumns"
        >
          <template
            slot="default-sendNum"
            slot-scope="scope">
            <el-button
              class="show-btn-dialog"
              type="text"
              @click="showDialogMethod(scope.row)"
            >{{ scope.row.sendNum }}</el-button>
          </template>
          <template
            slot="default-registrationNumber"
            slot-scope="scope">
            <div>
              <cell-registration
                :key="scope.row.registrationNumber"
                :regis-no="scope.row.registrationNumber"
                :content="'注册证已过期，点击查看详细信息'"
                :status="scope.row.isNoExpire"
                :regis-data="scope.row.registrationInfo"
              />
            </div>
            <!-- <el-button
              :disabled="!scope.row.registrationNumber||!scope.row.registrationId"
              v-html="regisNoButton(scope.row)"
              type="text"
              @click="showPdfRegistion(scope.row.registrationId)"
            /> -->
          </template>
        </el-editable>
        <!-- 分页模块 -->
        <el-pagination
          align="right"
          style="margin-top:20px;"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="receivePage.PAGE_NUMBER"
          :page-size="receivePage.size"
          :current-page="receivePage.page"
          :layout="receivePage.PAGINATION_LAYOUT"
          :total="receivePage.total"
        />
      </div>
      <!-- 术后还回信息 -->
      <div v-if="activeIndex === 2">
        <h3 class="title">病人信息</h3>
        <RecordInfo
          :record-form="patientInfoColumns"
          :record-data="returnTopInfo"/>
        <file-list
          :file-list-arr="topInfo.fileUrl"
        />
        <h3 class="title">订单信息</h3>
        <RecordInfo
          :record-form="headerFrom"
          :record-data="returnTopInfo">
          <template v-slot:recordInfoslot="slotProp">
            <div
              class="solt-info"
              v-if="activeIndex === 0||2||3">
              <div>
                <span class="left-span">
                  术后还回单号
                  <span class="right-span">{{ returnOrderCode.returnCode }}</span>
                </span>
                <span>
                  收货时间
                  <span>{{ returnOrderCode.returnCreatedAt }}</span>
                </span>
                <span>
                  收货人:
                  <span>
                    <span>{{ returnOrderCode.returnCreatedBy }}</span>
                  </span>
                </span>
              </div>
              <div>
                <span class="left-span">
                  还回产品总数
                  <span class="right-span">{{ returnOrderCode.returnNumCount }}</span>
                </span>
                <span>
                  品种数
                  <span>{{ returnOrderCode.returnCount }}</span>
                </span>
                <span>
                  金额合计:
                  <span>
                    <span class="price">{{ returnOrderCode.returnAmount | getFormatterPrice }}</span>
                  </span>
                </span>
              </div>
            </div>
          </template>
        </RecordInfo>
        <el-editable
          class="purchase-wholesale-detail-table"
          height="600"
          :data="returnOrderList"
          :columns="returnOperationColumns"
        >
          <template
            slot="default-returnNum"
            slot-scope="scope">
            <el-button
              class="show-btn-dialog"
              type="text"
              @click="showDialogMethod(scope.row)"
            >{{ scope.row.returnNum }}</el-button>
          </template>
          <template
            slot="default-registrationNumber"
            slot-scope="scope">
            <div>
              <cell-registration
                :key="scope.row.registrationNumber"
                :regis-no="scope.row.registrationNumber"
                :content="'注册证已过期，点击查看详细信息'"
                :status="scope.row.isNoExpire"
                :regis-data="scope.row.registrationInfo"
              />
            </div>
            <!-- <el-button
              :disabled="!scope.row.registrationNumber||!scope.row.registrationId"
              v-html="regisNoButton(scope.row)"
              type="text"
              @click="showPdfRegistion(scope.row.registrationId)"
            /> -->
          </template>
        </el-editable>
        <!-- 分页模块 -->
        <el-pagination
          align="right"
          style="margin-top:20px;"
          @size-change="returnHandleSizeChange"
          @current-change="returnHandleCurrentChange"
          :page-sizes="returnPage.PAGE_NUMBER"
          :page-size="returnPage.size"
          :current-page="returnPage.page"
          :layout="returnPage.PAGINATION_LAYOUT"
          :total="returnPage.total"
        />
      </div>
      <div v-if="activeIndex === 3">
        <h3 class="title">病人信息</h3>
        <RecordInfo
          :record-form="patientInfoColumns"
          :record-data="returnTopInfo"/>
        <file-list
          :file-list-arr="topInfo.fileUrl"
        />
        <h3 class="title">订单信息</h3>
        <RecordInfo
          :record-form="headerFrom"
          :record-data="returnTopInfo">
          <template v-slot:recordInfoslot="slotProp">
            <div
              class="solt-info"
              v-if="activeIndex === 0||2||3">
              <div>
                <span class="left-span">
                  消耗单号
                  <span class="right-span">{{ consumeOrderCode.consumeCode }}</span>
                </span>
                <span>
                  创建时间
                  <span>{{ consumeOrderCode.returnCreatedAt }}</span>
                </span>
                <span>
                  操作人:
                  <span>
                    <span>{{ consumeOrderCode.returnCreatedBy }}</span>
                  </span>
                </span>
              </div>
              <div>
                <span class="left-span">
                  消耗产品总数
                  <span class="right-span">{{ consumeOrderCode.returnNumCount }}</span>
                </span>
                <span>
                  品种数
                  <span>{{ consumeOrderCode.returnCount }}</span>
                </span>
                <span>
                  金额合计:
                  <span>
                    <span class="price">{{ consumeOrderCode.returnAmount | getFormatterPrice }}</span>
                  </span>
                </span>
              </div>
            </div>
          </template>
        </RecordInfo>
        <el-editable
          class="purchase-wholesale-detail-table"
          height="600"
          :data="consumeOrderList"
          :columns="consumeOperationColumns"
        >
          <template
            slot="default-consumeNum"
            slot-scope="scope">
            <el-button
              class="show-btn-dialog"
              type="text"
              :disabled="Number(scope.row.consumeNum)===0"
              @click="showDialogMethod(scope.row)"
            >{{ scope.row.consumeNum }}</el-button>
          </template>
          <template
            slot="default-registrationNumber"
            slot-scope="scope">
            <div>
              <cell-registration
                :key="scope.row.registrationNumber"
                :regis-no="scope.row.registrationNumber"
                :content="'注册证已过期，点击查看详细信息'"
                :status="scope.row.isNoExpire"
                :regis-data="scope.row.registrationInfo"
              />
            </div>
            <!-- <el-button
              :disabled="!scope.row.registrationNumber||!scope.row.registrationId"
              v-html="regisNoButton(scope.row)"
              type="text"
              @click="showPdfRegistion(scope.row.registrationId)"
            /> -->
          </template>
        </el-editable>
        <!-- 分页模块 -->
        <el-pagination
          align="right"
          style="margin-top:20px;"
          @size-change="consumeHandleSizeChange"
          @current-change="consumeHandleCurrentChange"
          :page-sizes="consumePage.PAGE_NUMBER"
          :page-size="consumePage.size"
          :current-page="consumePage.page"
          :layout="consumePage.PAGINATION_LAYOUT"
          :total="consumePage.total"
        />
      </div>
      <!-- </div> -->
    </el-container>
    <dialogInfo
      :dialog-title="dialogTitle"
      :dialog-visible.sync="dialogVisible"
      :card-columns="dialogListconcatColumns"
      :dialog-list="dialogList"
      :card-columns-info="cardSonConfirmedColumns"
      :dialog-list-info="dialogListInfo"
      @getInfo="getInfo"
      @closeDialog="closeDialog"
      :dialog-total="dialogTotal"
      ref="dialogInfo"
    />
    <follow-goods
      :is-show-follow-goods-list="isShowFollowGoodsList"
      :follow-goods-list-data="FollowGoodsListData"
      :role-type="roleType"
      :settle="settle"
      @cancelDialog="cancelDialog"
    />
  </div>
</template>

<script>
import tabs from '@components/tabs'
import RecordZoomCard from '@/moduleComponents/beforeSettle/distributorSide/purchasingManagement/accompaniedbygoods'
import RecordInfo from '@/moduleComponents/beforeSettle/distributorSide/purchasingManagement/record'
import { PAGE_NUMBER, PAGINATION_LAYOUT, PDF_LIMIT_SIZE } from '@const/common'
import paginationMixin from '@mixins/paginationMixin.js'
import ElEditable from '@components/el-editable'
import { formatDate, getFormatterPrice } from '@const/filter.js'
import { fileUpload } from '@const/api'
import CellRegistration from '@/moduleComponents/common/detail/cell-registration'
import { mapMutations } from 'vuex'
import { hasIn, cloneDeep } from 'lodash'
import dialogInfo from '@/moduleComponents/beforeSettle/distributorSide/purchasingManagement/dialogInfo'
import { getCertificate } from '@const/productCenterApiV2'
import {
  YyPssFollowOrdergetById,
  YyPssFollowOrderItemPageList, // 订单信息
  YyPssFollowOrderItemDeliveryPageList, // 发货信息
  YyPssFollowOrderGetDeliveryById,
  YyPssFollowOrderGetDistributorByItemId,
  YyReturnFollowItemGetReturnById,
  YyReturnFollowItemGetConsumeById,
  getReturnDisPageList,
  yyReturnFollowItemGetMsgById,
  YyReturnFollowItemReturnDisPageList,
  YyPssFollowOrderConsumeItemInfo,
  YyReturnFollowItemReturnProdItemInfo,
  wscSaleOrderPeerList
} from '@const/beforeSettleApi'
import {
  cardSonConfirmedColumns,
  statusArr,
  headerPartialCollectionColumns,
  detailPartialCollectionColumns,
  cardPartialCollectionColumns,
  detailTabList,
  returnOperationOrderColumns,
  returnOperationColumns,
  consumeOperationOrderColumns,
  consumeOperationColumns,
  patientInfoColumns,
  returnPatientInfoColumns,
  dialogListColumns,
  ORDER_STATUS,
  RecivePartialCollectionColumns,
  sexMap
} from './const'
import { regisNoButton, showPdfRegistion } from '@const/agencySaas'
import followGoods from '@/moduleComponents/beforeSettle/followGoodsNote'
import fileList from '@/moduleComponents/beforeSettle/fileList'
export default {
  mixins: [paginationMixin],
  data () {
    return {
      // 订单信息
      headerPartialCollectionColumns,
      // 收货信息列表
      cardPartialCollectionColumns,
      // 弹框收货信息详情
      cardSonConfirmedColumns,
      // 订单状态枚举
      statusArr,
      // 控制弹框是否显示
      dialogVisible: false,
      // 收货信息弹框详情数据
      dialogListInfo: [],
      // 收货信息弹框详情数据
      dialogList: [],
      // 订单信息列表表头信息
      detailPartialCollectionColumns,
      // 术后退回信息详情
      returnOperationOrderColumns,
      // 术后还回信息列表
      returnOperationColumns,
      // 手术消耗信息病人信息
      consumeOperationOrderColumns,
      // 手术消耗信息列表
      consumeOperationColumns,
      // 病人信息
      patientInfoColumns,
      returnPatientInfoColumns,
      reMarksVisible: false,
      dialogListColumns,
      dialogListconcatColumns: [],
      // 页码（订单信息）
      page: {
        PAGE_NUMBER,
        PAGINATION_LAYOUT
      },
      // 收货信息页码
      receivePage: {
        PAGE_NUMBER,
        PAGINATION_LAYOUT,
        page: 1,
        size: PAGE_NUMBER[0],
        total: 0
      },
      // 术后还回信息页码
      returnPage: {
        PAGE_NUMBER,
        PAGINATION_LAYOUT,
        page: 1,
        size: PAGE_NUMBER[0],
        total: 0
      },
      // 手术消耗信息页码
      consumePage: {
        PAGE_NUMBER,
        PAGINATION_LAYOUT,
        page: 1,
        size: PAGE_NUMBER[0],
        total: 0
      },
      // 弹框表头
      dialogTitle: '',
      // tab
      detailTabList,
      // 分页数组,用于添加多个分页
      pageList: [],
      insideTableLoading: false,
      partDetailTableLoading: false,
      // 收货信息列表
      deliveryDetailList: [],
      tableLoading: false,
      // 订单信息列表
      tableData: [],
      // 还回信息与预消耗信息头部详情
      returnTopInfo: {},
      rowTitle: 'bsDeliveryDistributorVOList',
      topData: {},
      topInfo: {},
      activeIndex: 0,
      fileList: [],
      ordertableData: [],
      reciveTopInfo: {},
      RecivePartialCollectionColumns,
      dialogSendId: '',
      dialogTotal: 0,
      returnOrderList: [],
      returnOrderCode: {},
      consumeOrderCode: {},
      consumeOrderList: [],
      isShowFollowGoodsList: false,
      FollowGoodsListData: [],
      roleType: 2,
      settle: 1 // 1-结算前，2-结算后
    }
  },
  components: {
    RecordZoomCard,
    RecordInfo,
    ElEditable,
    tabs,
    dialogInfo,
    followGoods,
    fileList,
    CellRegistration
  },
  watch: {
    activeIndex: {
      handler () {
        let arr = []
        if (this.activeIndex === 1) {
          this.dialogTitle = '发货记录'
          arr = [{ prop: 'sendNum', label: '发货数量', width: 150 }]
          this.dialogListconcatColumns = this.dialogListColumns.concat(arr)
        } else if (this.activeIndex === 2) {
          this.dialogTitle = '术后还回收货记录'
          arr = [{ prop: 'returnNum', label: '术后还回收货数量', width: 150 }]
          this.dialogListconcatColumns = this.dialogListColumns.concat(arr)
        } else if (this.activeIndex === 3) {
          this.dialogTitle = '消耗记录'
          this.dialogListconcatColumns = this.dialogListColumns.concat([
            { prop: 'consumeNum', label: '消耗数量', width: 150 }
          ])
        }
      }
    }
  },
  computed: {
    id () {
      return this.$route.query.id
    },
    headerFrom () {
      return this.headerPartialCollectionColumns
    },
    listColumns () {
      let arr = cloneDeep(this.detailPartialCollectionColumns)
      arr.splice(8, 3)
      let obj = { prop: 'price', label: '单价（元）', width: 130 }
      arr.splice(8, 1, obj)
      return arr
    },
    cardColumns () {
      return this.cardPartialCollectionColumns
    },
    tabSliceList () {
      if (Number(this.$route.query.status) === 3) {
        let detailTabList = cloneDeep(this.detailTabList)
        detailTabList[2].disabled = true
        detailTabList[3].disabled = true
        return detailTabList
      } else if (Number(this.$route.query.status) === 4) {
        let detailTabList = cloneDeep(this.detailTabList)
        return detailTabList
      } else {
        let detailTabList = cloneDeep(this.detailTabList)
        detailTabList[1].disabled = true
        detailTabList[2].disabled = true
        detailTabList[3].disabled = true
        return detailTabList
      }
    }
  },
  filters: {
    getFormatterPrice
  },
  mounted () {
    this.initNavButtons()
    this.getDeverInfo()
    this.getDetailList()
    // this.getReciveInfo()
    // 获取术后退回明细信息
    // this.getReturnListInfo()
    // this.getCunSumeInfo()
    let status = Number(this.$route.query.status)
    if (status === 4 || status === 3) {
      this.patientInfoColumns[2][1].label = '手术名称'
    } else {
      this.patientInfoColumns[2][1].label = '拟手术名称'
    }
  },
  methods: {
    ...mapMutations(['changeLayoutHandle']),
    regisNoButton,
    showPdfRegistion,
    // 初始化 导航栏 按钮组
    initNavButtons () {
      let status = Number(this.$route.query.status)
      let arr = []
      if (status === 3 || status === 4) {
        arr = [
          { type: 'button', val: '返回', handle: this.back },
          {
            type: 'primary',
            val: '查看随货同行单',
            handle: this.lookFollowGoodsNote
          }
        ]
      } else {
        arr = [{ type: 'button', val: '返回', handle: this.back }]
      }
      const btn = {
        type: 'btn',
        arr: arr
      }
      this.changeLayoutHandle(btn)
    },
    // 查看随货同行单
    lookFollowGoodsNote () {
      this.$axios
        .$post(wscSaleOrderPeerList, {
          purchaseOrderId: this.topInfo.hspFollowId,
          saleOrderId: this.topInfo.pssFollowId,
          roleType: this.roleType // 登录角色（1-医院 2-配送商)
        })
        .then(res => {
          let data = res.payload || []
          // 如果有多个随货同行单，就弹框让其选择
          // 如果只有一个，直接弹出
          if (data.length > 0) {
            this.FollowGoodsListData = data
            this.isShowFollowGoodsList = true
          } else {
            this.$message({
              type: 'warning',
              message: '此订单还没有随货同行单！'
            })
          }
        })
    },
    cancelDialog () {
      this.isShowFollowGoodsList = false
    },
    getReciveInfo () {
      this.$axios({
        method: 'get',
        url: YyPssFollowOrderGetDeliveryById,
        params: {
          pssFollowId: this.$route.query.id,
          type: 1
        }
      }).then(res => {
        let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
        for (let key in obj) {
          obj[key] = obj[key] + ``
          if (!obj[key] || obj[key] === 'null') {
            obj[key] = `--`
          }
          if (key === 'orderStatus') {
            obj[key] = statusArr[obj[key]]
          }
        }
        this.reciveTopInfo = obj
      })
    },
    isJpg (url) {
      let arr = url.split('.')
      let toLowrCaseUrl = arr[arr.length - 1].toLowerCase()
      if (
        toLowrCaseUrl === 'jpg' ||
        toLowrCaseUrl === 'png' ||
        toLowrCaseUrl === 'jpeg' ||
        toLowrCaseUrl === 'bpg'
      ) {
        return 'jpg'
      } else if (toLowrCaseUrl === 'pdf') {
        return 'pdf'
      } else {
        if (toLowrCaseUrl !== '--' || !toLowrCaseUrl) {
          return 'downLoad'
        }
      }
      // } else if (
      //   toLowrCaseUrl === 'xls' ||
      //   toLowrCaseUrl === 'xlsx' ||
      //   toLowrCaseUrl === 'docx' ||
      //   toLowrCaseUrl === 'doc'
      // ) {
      //   return 'downLoad'
      // }
    },
    getReturnTopInfo () {
      this.$axios({
        method: 'get',
        url: yyReturnFollowItemGetMsgById,
        params: {
          pssFollowId: this.$route.query.id
        }
      }).then(res => {
        let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
        if (obj) {
          for (let key in obj) {
            obj[key] = obj[key] + ``
            if (!obj[key] || obj[key] === 'null') {
              obj[key] = `--`
            }
            if (key === 'orderStatus') {
              obj[key] = statusArr[obj[key]]
            }
            if (key === 'sickSex') {
              obj[key] = sexMap[obj[key]]
            }
          }
          this.returnTopInfo = obj
        }
      })
    },
    getReturnListInfo () {
      this.$axios({
        method: 'post',
        url: YyReturnFollowItemGetReturnById,
        data: {
          pssFollowId: this.$route.query.id,
          page: this.returnPage.page,
          pageSize: this.returnPage.size
        }
      }).then(res => {
        let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
        this.returnOrderCode = {}
        let arr = []
        for (let key in obj) {
          if (key !== 'orderItemVOList') {
            obj[key] = obj[key] + ``
            if (!obj[key] || obj[key] === 'null') {
              obj[key] = `--`
            }
            if (key === 'orderStatus') {
              obj[key] = statusArr[obj[key]]
            }
            if (key === 'sickSex') {
              obj[key] = sexMap[obj[key]]
            }
            this.returnOrderCode[key] = obj[key]
          } else if (key === 'orderItemVOList') {
            arr = obj[key].content
            this.returnPage.total = obj[key].totalElements
          }
        }
        this.returnOrderList = arr
      })
    },
    getCunSumeInfo () {
      this.$axios({
        method: 'post',
        url: YyReturnFollowItemGetConsumeById,
        data: {
          page: this.consumePage.page,
          pageSize: this.consumePage.size,
          pssFollowId: this.$route.query.id
        }
      }).then(res => {
        let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
        this.consumeOrderCode = {}
        let arr = []
        for (let key in obj) {
          if (key !== 'orderItemVOList') {
            obj[key] = obj[key] + ``
            if (!obj[key] || obj[key] === 'null') {
              obj[key] = `--`
            }
            if (key === 'orderStatus') {
              obj[key] = statusArr[obj[key]]
            }
            if (key === 'sickSex') {
              obj[key] = sexMap[obj[key]]
            }
            this.consumeOrderCode[key] = obj[key]
          } else if (key === 'orderItemVOList') {
            arr = obj[key].content
            this.consumePage.total = obj[key].totalElements
          }
        }
        this.consumeOrderList = arr
      })
    },
    // 获取弹框详情列表
    getInfo (page = '1', pageSize = '20') {
      let url = YyPssFollowOrderGetDistributorByItemId
      if (this.activeIndex === 1) {
        url = YyPssFollowOrderGetDistributorByItemId
        this.$axios({
          method: 'get',
          url,
          params: {
            pssFollowDetailId: this.dialogSendId,
            page: page,
            pageSize: pageSize
          }
        }).then(res => {
          let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
          this.dialogListInfo = obj.content
          this.dialogTotal = obj.totalElements
        })
      } else if (this.activeIndex === 2) {
        url = YyReturnFollowItemReturnProdItemInfo
        this.$axios({
          method: 'post',
          url,
          data: {
            pssFollowDetailId: this.dialogSendId,
            page: page,
            pageSize: pageSize
          }
        }).then(res => {
          let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
          this.dialogListInfo = obj.content
          this.dialogTotal = obj.totalElements
        })
      } else if (this.activeIndex === 3) {
        url = YyPssFollowOrderConsumeItemInfo
        this.$axios({
          method: 'post',
          url,
          data: {
            pssFollowDetailId: this.dialogSendId,
            page: page,
            pageSize: pageSize
          }
        }).then(res => {
          let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
          this.dialogListInfo = obj.content
          this.dialogTotal = obj.totalElements
        })
      }
    },
    getDetailList () {
      let url = ''
      if (this.activeIndex === 1) {
        url = YyPssFollowOrderItemDeliveryPageList
      } else {
        url = YyPssFollowOrderItemPageList
      }
      this.$axios({
        method: 'post',
        url: url,
        data: {
          pssFollowId: this.$route.query.id,
          page: this.activeIndex === 0 ? this.page.page : this.receivePage.page,
          pageSize:
            this.activeIndex === 0 ? this.page.size : this.receivePage.size
        }
      }).then(res => {
        let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
        this.ordertableData = obj.content
        if (this.activeIndex === 0) {
          this.page.total = obj.totalElements
        } else {
          this.receivePage.total = obj.totalElements
        }
      })
    },
    getDeverInfo () {
      this.$axios({
        method: 'get',
        url: YyPssFollowOrdergetById,
        params: {
          pssFollowId: this.$route.query.id
        }
      }).then(res => {
        let obj = hasIn(res, 'data.payload') ? res.data.payload : {}
        for (let key in obj) {
          if (typeof obj[key] === 'number') {
            continue
          }
          obj[key] = obj[key] || ``
          if (key === 'fileUrl') {
            obj[key] = obj[key] || []
          }
          if (!obj[key] || obj[key] === 'null') {
            obj[key] = `--`
          }
          if (key === 'orderStatus') {
            obj[key] = ORDER_STATUS[obj[key]]
          }
          if (key === 'sickSex') {
            obj[key] = sexMap[obj[key]]
          }
        }
        this.topInfo = obj
        const { fileUrl } = this.topInfo
        this.topInfo.fileUrl = fileUrl || []
        this.topInfo.fileUrl.forEach(item => {
          item.type = item.fileUrl.split('').reverse().join('').split('.')[0].split('').reverse().join('').toLowerCase()
        })
      })
    },
    // 点击收货数量显示弹框
    showDialogMethod (data) {
      this.dialogVisible = true
      let arr = []
      arr.push(data)
      this.dialogList = arr
      this.dialogSendId = data.pssFollowDetailId
      this.getInfo()
    },
    // 返回上一级
    back () {
      this.$router.go(-1)
    },
    // 订单信息页码更改
    getItems () {
      this.getDetailList()
    },
    // tab切换
    handleReturnIndex (ind) {
      this.activeIndex = ind
      if (this.activeIndex === 0 || this.activeIndex === 1) {
        this.getDetailList()
      }
      if (this.activeIndex === 1) {
        this.getReciveInfo()
      } else if (this.activeIndex === 2) {
        this.getReturnListInfo()
        this.getReturnTopInfo()
      } else if (this.activeIndex === 3) {
        this.getCunSumeInfo()
        this.getReturnTopInfo()
      }
    },
    // 页码更改
    handleSizeChange (size) {
      this.receivePage.size = size
      this.getDetailList()
    },
    // 切换不一样的页面,重置一切数据
    handleCurrentChange (page) {
      this.receivePage.page = page
      this.getDetailList()
    },
    // 页码更改
    returnHandleSizeChange (size) {
      this.returnPage.size = size
      this.getReturnListInfo()
      //   this.getDeliveryDetailList()
    },
    // 切换不一样的页面,重置一切数据
    returnHandleCurrentChange (page) {
      this.returnPage.page = page
      this.getReturnListInfo()
      //   this.getDeliveryDetailList()
    },
    consumeHandleSizeChange (size) {
      this.consumePage.size = size
      this.getCunSumeInfo()
    },
    consumeHandleCurrentChange (page) {
      this.consumePage.page = page
      this.getCunSumeInfo()
    },
    closeDialog () {
      this.dialogVisible = false
      this.dialogListInfo = []
      this.dialogList = []
    }
  }
}
</script>
<style lang="less">
.purchasing-purchase-wholesale-detail {
  height: 100%;
  display: flex;

  .registercard-box {
    flex-direction: column;
    .title {
      padding-left: 16px;
      box-sizing: border-box;
    }
    .tab-info {
      padding-bottom: 10px;
    }
    .patient-title {
      border: 1px solid #999;
      margin: 16px;
    }
    .el-form-item__label {
      width: 110px !important;
    }
    .price {
      color: #000;
    }
    .info-title {
      height: 36px;
      line-height: 36px;
      font-size: 16px;
      padding-left: 16px;
      // background: red;
      span {
        margin-right: 16px;
      }
    }
    .el-form-item__content {
      height: 40px;
      line-height: 40px;
      padding-top: 0 !important;
    }
    .solt-info {
      div {
        height: 36px;
        line-height: 36px;
        font-size: 16px;
      }
    }
    .pagination {
      padding-top: 10px;
      display: flex;
      justify-content: flex-end;
      padding-right: 0;
    }
  }
  .header-limit {
    .el-input__inner {
      width: 200px;
    }
    .el-date-editor {
      width: 368px;
    }
  }
  .dialog-info {
    margin-top: 46px;
  }
  .upload-box {
    width: 304px;
    display: flex;
    justify-content: center;
    align-items: center;

    .el-upload {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      border: 1px solid #cdd2dc;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 22px;
      color: rgba(35, 113, 197, 1);

      .avatar {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }
  }
}
.isfelx {
  display: flex;
}
</style>
